package com.uetoken.cn.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.widget.ImageView;

import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.uetoken.cn.R;
import com.uetoken.cn.bean.BankListBean;
import com.uetoken.cn.utils.GlideApp;

import java.util.List;

/**
 * @author 谢杨
 * @time 2018/9/11 9:19
 * @class 描述:
 */
public class BankListAdapter extends BaseQuickAdapter<BankListBean.DataBean,BaseViewHolder> {
    public BankListAdapter(int layoutResId, @Nullable List<BankListBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BankListBean.DataBean item) {
        final ConstraintLayout constraintLayout = helper.getView(R.id.cst_item_bind_bank);

        SimpleTarget<Drawable> simpleTarget = new SimpleTarget<Drawable>() {
            @Override
            public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
                constraintLayout.setBackground(resource);
            }
        };
        GlideApp.with(mContext).load(item.getPic()).into(simpleTarget);

        GlideApp.with(mContext).load(item.getLogo()).into((ImageView) helper.getView(R.id.iv_item_bind_bank_logo));
        helper.setText(R.id.tv_item_bank_name,item.getBankname());
        helper.setText(R.id.tv_item_bind_bank_number,item.getCardno());
        helper.addOnClickListener(R.id.tv_item_bind_bank_delete);
    }
}
